﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;

namespace SocketPolicyService
{
    public partial class Service : ServiceBase
    {
        PolicyServer PolicyServer;

        public Service()
        {
            InitializeComponent();


        }

        protected override void OnStart(string[] args)
        {
            try
            {
                PolicyServer = new PolicyServer(SocketPolicy.Policy);
            }
            catch (Exception ex) { EventLog.WriteEntry(String.Format("Socket Policy Service failed startting {0}", ex), EventLogEntryType.Error); }
        }

        protected override void OnStop()
        {
            try
            {
                PolicyServer.Close();
            }
            catch (Exception ex) { EventLog.WriteEntry(String.Format("Socket Policy Service failed stopping {0}", ex), EventLogEntryType.Error); }
        }
    }
}
